package com.example.a_buffer;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;

public class DemoProperties {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.setProperty("name","张三");
        properties.setProperty("age","18");
        properties.setProperty("address","北京");
        Set<String> set = properties.stringPropertyNames();
        for (String key : set) {
            System.out.println(properties.get(key));
        }

        try(FileInputStream fis = new FileInputStream("jdbc.properties");) {
            Properties properties1 = new Properties();
            properties1.load(fis);

            System.out.println("fis对象为：" + properties1);
            Set<String> set1 = properties1.stringPropertyNames();
            for (String key1 : set1) {
                System.out.println(properties1.get(key1));
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
